#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import allure
import logging
# from pylenium.driver import log
# from selenium.webdriver import ActionChains


class Keyboard:
    def __init__(self,draPage):
        from dragon.page import DraPage
        self.draPage:DraPage=draPage
    
    def arrow_up(self):
        stepText = f'步骤：按光标键上'
        with allure.step(stepText):
            logging.info(stepText)
        return self

    def arrow_down(self):
        stepText = f'步骤：按光标键下'
        with allure.step(stepText):
            logging.info(stepText)
            self._action.send_keys(self.keys.ARROW_DOWN).perform()
        return self

    def arrow_left(self):
        stepText = f'步骤：按光标键左'
        with allure.step(stepText):
            logging.info(stepText)
            self._action.send_keys(self.keys.ARROW_LEFT).perform()
        return self

    def arrow_right(self):
        stepText = f'步骤：按光标键右'
        with allure.step(stepText):
            logging.info(stepText)
            self._action.send_keys(self.keys.ARROW_RIGHT).perform()
        return self

    def page_up(self):
        stepText = f'步骤：按PAGEUP'
        with allure.step(stepText):
            logging.info(stepText)
            self._action.send_keys(self.keys.PAGE_UP).perform()
        return self

    def page_down(self):
        stepText = f'步骤：按PAGEDOWN'
        with allure.step(stepText):
            logging.info(stepText)
            self._action.send_keys(self.keys.PAGE_DOWN).perform()
        return self

    def home(self):
        stepText = f'步骤：按HOME'
        with allure.step(stepText):
            logging.info(stepText)
            self._action.send_keys(self.keys.HOME).perform()
        return self

    def end(self):
        stepText = f'步骤：按END'
        with allure.step(stepText):
            logging.info(stepText)
            self._action.send_keys(self.keys.END).perform()
        return self

    def escape(self):
        stepText = f'步骤：按ESC'
        with allure.step(stepText):
            logging.info(stepText)
            self._action.send_keys(self.keys.ESCAPE).perform()
        return self

    def enter(self):
        stepText = f'步骤：按ENTER'
        with allure.step(stepText):
            logging.info(stepText)
            self._action.send_keys(self.keys.ENTER).perform()
        return self